package com.oa.ylms.apps.dao.archives.impl;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.oa.ylms.apps.dao.archives.IAvatarInfoDao;
import com.oa.ylms.apps.entity.archives.AvatarInfoValue;

public class AvatarInfoDaoImpl extends HibernateDaoSupport implements
		IAvatarInfoDao {

	@Override
	public int addAvatarInfo(AvatarInfoValue avatarInfo) throws Exception {
		if(avatarInfo != null){
			this.getHibernateTemplate().save(avatarInfo);
			return avatarInfo.getAvatarId();
		}
		return 0;
	}

	@Override
	public boolean editAvatarInfo(AvatarInfoValue avatarInfo) throws Exception {
		if(avatarInfo != null){
			try{
				this.getHibernateTemplate().update(avatarInfo);
			}catch(Exception e){
				return false;
			}
			return true;
		}
		return false;
	}

	@Override
	public AvatarInfoValue queryByAvatarId(AvatarInfoValue avatarInfo)
			throws Exception {
		if(avatarInfo != null){
			return (AvatarInfoValue) this.getHibernateTemplate().get(AvatarInfoValue.class, avatarInfo.getAvatarId());
		}
		return null;
	}
}
